unassigned variable

Hello.

I have a problem. I created a code in november of 2012, I tested and everything. Its was working. But now I'm getting the message that the variable is unassigned.

The thing is I dont remember how the did some things in this code.

So if anyone can help see the error in the dxl, or at least the reason why, I would appreciate.

Thanks...

void createBSD(){    
Folder f = current
BaselineSetDefinition newBSD = null
string bsdname = get (bsInput)
string errmess
errmess = create(f, bsdname, "BaselineSet def for data", newBSD)

}

void addBSD(){
BaselineSetDefinition BSD
BaselineSet newBS
Item i
Folder f = current
string errmess
Skip moduleSkip = create
bool major = true
int selItemToken
ModName_ selMod
 
for BSD in current Folder do
{
    lock(BSD)
 for (selItemToken=0; selItemToken<noElems(selectedListView); selItemToken++) {
  raise(selectModulesDB)
  i = item(get(selectedListView, selItemToken))
 
  if (type(i) == "Formal"){
  string modpath = fullName(i)
        selMod = module(modpath)
     addModule(selMod, BSD)
   
  put(moduleSkip, selItemToken, selMod)
 } 
}

 create(BSD, major, "", "", newBS)
    unlock(BSD)
 string check = addBaselines(moduleSkip, newBS)
 close(newBS)
 }  
   
 save(BSD)
 delete(moduleSkip)  
}

 


braolive - Wed Jun 12 14:07:02 EDT 2013

Re: unassigned variable
braolive - Wed Jun 12 14:30:48 EDT 2013

I found the problem.

The baselineSet is not being closed. Is the close or the save part that is wrong?

Re: unassigned variable
llandale - Wed Jun 12 15:50:04 EDT 2013

It would help if you told us which line of code was giving the error.

I don't know about this case, but there are some "close" or "delete" commands that leave the variable undefined rather than null.

I cannot see the code well, but it appears to me the "save(BSD)" command is outside the loop when it should be inside.  However, the BSD variable should be valid and contain the last bsd in the loop.

-Louie

Re: unassigned variable
braolive - Thu Jun 13 06:28:22 EDT 2013

llandale - Wed Jun 12 15:50:04 EDT 2013

It would help if you told us which line of code was giving the error.

I don't know about this case, but there are some "close" or "delete" commands that leave the variable undefined rather than null.

I cannot see the code well, but it appears to me the "save(BSD)" command is outside the loop when it should be inside.  However, the BSD variable should be valid and contain the last bsd in the loop.

-Louie

I have find the solution.

I unlock the baseline before the addModules(), then I forgot to lock it again. The problem is more with the order of the commands. I read the dxl reference manual and change the dxl to this:

void addBSD(){
BaselineSetDefinition BSD
BaselineSet newBS
Item i
Folder f = current
string errmess
Skip moduleSkip = create
bool major = true
int selItemToken
ModName_ selMod
 
for BSD in current Folder do
{
    lock(BSD)
 for (selItemToken=0; selItemToken<noElems(selectedListView); selItemToken++) {
  raise(selectModulesDB)
  i = item(get(selectedListView, selItemToken))
 
  if (type(i) == "Formal"){
  string modpath = fullName(i)
        selMod = module(modpath)
     addModule(selMod, BSD)
   
  put(moduleSkip, selItemToken, selMod)
 } 
}

 create(BSD, major, "", "", newBS)
    unlock(BSD)
 string check = addBaselines(moduleSkip, newBS)
 
 }  
 save(BSD)
 lock(BSD)
 close(newBS)
 delete(moduleSkip)  
}

now its working.